package com.zzuli.dcxt.service.impl;

import com.zzuli.dcxt.dao.DishesMapper;
import com.zzuli.dcxt.entiy.Category;
import com.zzuli.dcxt.entiy.Dishes;
import com.zzuli.dcxt.service.DishesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DishesServiceImpl implements DishesService {
    @Autowired
    private DishesMapper dishesMapper;
    @Override
    public List<Dishes> selectAll() {
        return dishesMapper.selectAll();
    }

    @Override
    public void addDishes(Dishes dishes) {
        dishesMapper.add(dishes);
    }

    @Override
    public Dishes selectOne(int id) {
        return dishesMapper.selectOne(id);
    }

    @Override
    public void update(Dishes dishes) {
        dishesMapper.update(dishes);
    }

    @Override
    public void delete(int id) {
        dishesMapper.delete(id);
    }

    @Override
    public List<Category> getCategory() {
        return dishesMapper.getCategory();
    }

    @Override
    public String searchLbByKeyword(String keyword) {
        List<String> list = dishesMapper.searchLbByKeyword(keyword);
        String strs = "";

        if (list.size() > 0) {
            for (String str : list) {
                strs += str+",";
            }
            return strs.substring(0, strs.length() - 1);
        }

        return null;
    }
}
